package com.ruoyi.tjbb.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tjbb.domain.SysTjbbJcwljl;
import com.ruoyi.tjbb.service.ISysTjbbJcwljlService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 进出围栏记录Controller
 * 
 * @author ruoyi
 * @date 2023-09-26
 */
@RestController
@RequestMapping("/tjbb/xsfx/jcwljl")
public class SysTjbbJcwljlController extends BaseController
{
    @Autowired
    private ISysTjbbJcwljlService sysTjbbJcwljlService;

    /**
     * 查询进出围栏记录列表
     */
    @PreAuthorize("@ss.hasPermi('tjbb/xsfx:jcwljl:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysTjbbJcwljl sysTjbbJcwljl)
    {
        startPage();
        List<SysTjbbJcwljl> list = sysTjbbJcwljlService.selectSysTjbbJcwljlList(sysTjbbJcwljl);
        return getDataTable(list);
    }

    /**
     * 导出进出围栏记录列表
     */
    @PreAuthorize("@ss.hasPermi('tjbb/xsfx:jcwljl:export')")
    @Log(title = "进出围栏记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysTjbbJcwljl sysTjbbJcwljl)
    {
        List<SysTjbbJcwljl> list = sysTjbbJcwljlService.selectSysTjbbJcwljlList(sysTjbbJcwljl);
        ExcelUtil<SysTjbbJcwljl> util = new ExcelUtil<SysTjbbJcwljl>(SysTjbbJcwljl.class);
        util.exportExcel(response, list, "进出围栏记录数据");
    }

    /**
     * 获取进出围栏记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('tjbb/xsfx:jcwljl:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysTjbbJcwljlService.selectSysTjbbJcwljlById(id));
    }

    /**
     * 新增进出围栏记录
     */
    @PreAuthorize("@ss.hasPermi('tjbb/xsfx:jcwljl:add')")
    @Log(title = "进出围栏记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysTjbbJcwljl sysTjbbJcwljl)
    {
        return toAjax(sysTjbbJcwljlService.insertSysTjbbJcwljl(sysTjbbJcwljl));
    }

    /**
     * 修改进出围栏记录
     */
    @PreAuthorize("@ss.hasPermi('tjbb/xsfx:jcwljl:edit')")
    @Log(title = "进出围栏记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysTjbbJcwljl sysTjbbJcwljl)
    {
        return toAjax(sysTjbbJcwljlService.updateSysTjbbJcwljl(sysTjbbJcwljl));
    }

    /**
     * 删除进出围栏记录
     */
    @PreAuthorize("@ss.hasPermi('tjbb/xsfx:jcwljl:remove')")
    @Log(title = "进出围栏记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysTjbbJcwljlService.deleteSysTjbbJcwljlByIds(ids));
    }
}
